#pragma once
#include "DeviceState.h"
#include "DeviceStateIdle.h"
#include "DeviceStateRinging.h"
#include "DeviceStateConnected.h"
#include <windows.h>
#include "SanhuiCardStateDef.h"


namespace DeviceStates{

	//enum to state class ,ref modern c++ design 2.5:type2type.

template <EDeviceState StateValue,typename StateName>
class enum2State
{
public:
	typedef StateName StateClass;
	enum{state = StateValue};
};

/*template < typename StateValueType >
class enum2DynState
{
public:
	enum2DynState( StateValueType value )
		:state( value )
	{}
	StateValueType state;
};*/

#define Device_State_TrunkIdle	enum2State<DEVICE_STATE_TRUNK_IDLE,CDeviceStateIdle>()
#define Device_State_ExtIdle	enum2State<DEVICE_STATE_EXT_IDLE,CDeviceStateIdle>()
#define Device_State_Ringing	enum2State<DEVICE_STATE_RINGING,CDeviceStateRinging>()
#define Device_State_Connected	enum2State<DEVICE_STATE_CONNECTED,CDeviceStateConnected>()

	


class CDeviceStatePool
{
public:
	CDeviceStatePool(void);
	~CDeviceStatePool(void);
	template < EDeviceState state, typename stateName>
	CDeviceState* createState(const enum2State< state,stateName >& t )
	{
		return new stateName();
	}

	/*CDeviceState* createNewState( const enum2DynState< EDeviceState>& newState )
	{
		return NULL;
	}*/
};

}
